package org.ysu.controller;

import io.minio.errors.*;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.ysu.core.YsuException;
import org.ysu.dto.CombinedFormData;
import org.ysu.service.UpInterviewService;
import org.ysu.vo.ResultVO;

import javax.annotation.Resource;
import java.io.IOException;
import java.security.InvalidKeyException;
import java.security.NoSuchAlgorithmException;

@RestController
@RequestMapping("/upInterview")
public class UpInterviewController {
    @Resource
    UpInterviewService upInterviewService;
    @PostMapping("/add")
    public ResultVO<Boolean> add(CombinedFormData combinedFormData) throws ServerException, InsufficientDataException, ErrorResponseException, IOException, NoSuchAlgorithmException, InvalidKeyException, InvalidResponseException, XmlParserException, InternalException {
        try {
            System.out.println(combinedFormData);
        } catch (Exception e) {
            throw new YsuException("信息输入有误，请仔细检查");
        }
        return ResultVO.success(upInterviewService.add(combinedFormData),"录入走访信息成功");
    }


}
